package com.samphanie.dries.service.impl;

import com.samphanie.dries.common.Constants;
import com.samphanie.dries.component.AliComponent;
import com.samphanie.dries.service.ISmsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2021/3/3 15:48
 */
@Slf4j
@Service
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = "dries.sms-provider", name = "name", havingValue = "ali")
public class AliSmsServiceImpl implements ISmsService {

    private final AliComponent aliComponent;

    @Override
    public void send(String mobile, String msg) {
        Map<String, Object> params = new HashMap<>();
        params.put("code", msg);
        aliComponent.sendSms(mobile, Constants.smsTypeEnum.REGISTER_CODE.getType(), params);
    }

}
